#include<stdio.h>
#include<conio.h>
#include<string.h>
#include<math.h>
#include"calculator.h"
void main(){
  int chon, done = 0;

  do {
    chon = choose();
    switch(chon)
    {
          case 1:
               calculator();
               break;
          /*case 2:
               multiplication_tables();
               break;
          case 3:
               printf_ordered_numbers();
               break;
          case 4:
               max();
          case 5:
               atm_withdraw();
               break;*/
          case 0 : done = 1;
    }
  } while (!done);
}
int choose(){
	char choice;
system("cls");
printf("Enter a number to choose the function:");
printf("\n1. Calculator");
printf("\n2. Multiplication tables");
printf("\n3. Print number in the order");
printf("\n4. Find the max and min number");
printf("\n5. How the ATM machines give you money when you withdraw?");
printf("\n____And your choice is: ");
 do {
    choice = getch();
  } while (choice<'0' || choice>'1');
  return choice-'0';
/*choice=pr_i;*/
}/*this function have duty to give the user the option for function that will be excuted in the main();*/
int calculator(){
    int a,b,c_i;
    float r;
    system("cls");
    printf("\n1.Multi it");
    printf("\n2.Devide it");
    printf("\n3.Plus it");
    printf("\n4.Minus it");
    printf("\n0.Previous menu");
    printf("\nEnter the first number:");
    scanf("%d",&a);
    if(!c_i)
    main();
    printf("Enter the second number:");
    scanf("%d",&b);
    choose_cal:switch(c_i){
                case 1:
                     r=multi(a,b);
                     break;
                case 2:
                     r=divide(a,b);
                     break;
                case 3:
                     r=plus(a,b);
                     break;
                case 4:
                     r=minus(a,b);
                     break;
                default:
                printf("Enter your choice:");
                scanf("%d",&c_i);
                goto choose_cal;
                break;
                }
       printf("The result is %3.2f",r);
       getch();
       calculator();
                }
    
